package com.example.q_kang.hhh.home;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.q_kang.hhh.R;
import com.hjq.toast.ToastUtils;
import com.sskj.base.MVPActivity;
import com.sskj.base.base.App;
import com.sskj.base.bean.PaiDanCommonBean;
import com.sskj.base.utils.ClickUtil;
import com.sskj.base.view.ToolBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author Hey
 * Create at  2019/04/10
 */
public class CreateCoinActivity extends MVPActivity<CreateCoinPresenter> {


    @BindView(R.id.toolbar)
    ToolBarLayout toolbar;
    @BindView(R.id.tv_honest)
    TextView tvHonest;
    @BindView(R.id.tv_jihuo)
    TextView tvJihuo;
    @BindView(R.id.tv_limit)
    TextView tvLimit;
    @BindView(R.id.et_pwd)
    EditText etPwd;
    @BindView(R.id.et_amount)
    EditText etAmount;
    @BindView(R.id.btn_submit)
    Button btnSubmit;

    @Override
    public int getLayoutId() {
        return R.layout.activity_create_coin;
    }

    @Override
    public CreateCoinPresenter getPresenter() {
        return new CreateCoinPresenter();
    }

    @Override
    public void initView() {
        toolbar.setLeftButtonOnClickListener(view -> finish());
        ClickUtil.click(300, btnSubmit, view -> {
            if (TextUtils.isEmpty(getEtext(etAmount))) {
                ToastUtils.show(App.INSTANCE.getString(R.string.appJavaCreateCoinActivity1));
                return;
            }
            if (TextUtils.isEmpty(getEtext(etPwd))) {
                ToastUtils.show(App.INSTANCE.getString(R.string.appJavaCreateCoinActivity2));
                return;
            }
            mPresenter.createCoin(getEtext(etAmount), getEtext(etPwd));
        });

    }

    @Override
    public void initData() {
        mPresenter.getCreatePaidanMsg();

    }

    public static void start(Context context) {
        Intent intent = new Intent(context, CreateCoinActivity.class);
        context.startActivity(intent);
    }

    public void showPaidan(PaiDanCommonBean data) {
        if (data == null) {
            return;
        }
        tvHonest.setText(data.getCxNum());
        tvJihuo.setText(data.getJhNum());
        tvLimit.setText(App.INSTANCE.getString(R.string.creatCoin1) + data.getXyjhNum()
                + App.INSTANCE.getString(R.string.creatCoin2) + data.getXycxNum()
                + App.INSTANCE.getString(R.string.creatCoin3));
    }
}
